<?php


require_once('config.php');
require_once(BASE_URL.'includes/core.cleaning.functions.php');
require_once(BASE_URL.'includes/core.functions.class.php');
require_once(BASE_URL.'includes/core.upload.theme.class.php');
require_once(BASE_URL.'includes/core.theme.manger.class.php');
require_once(BASE_URL.'includes/admin/core.admin.class.php');
$admin = new admin;
$theme = new themeManager;

if ($_GET['login'] == true) {
	if($_POST['login']) {
		$set = $admin->set_validation($_POST['username'], $_POST['password']);
		if($set == false) {
			$sys_content = $admin->message('error', "Whoops! Invalid Login!", "Please try entering the username and password again.");
		}
		else {
			$admin->validate("", "admin.php");
		}
	}
	include(BASE_URL.'includes/admin/pages/login.php');
	exit();
}
else {
	$admin->validate(THEME_URL."admin.php?login=true", "");
}
if($_GET['page'] && isset($_GET['page'])) {
	$admin->page_info['id'] = $_GET['page'];
}
elseif ($_GET['logout'] == "true") {
	$_SESSION = array();
	session_destroy();
	header('location: '.THEME_URL);
}
else {
	$admin->page_info['id'] = "home";
}



//$admin->displayPage($admin->page_info['id']);


define("INCLUDE_URL", BASE_URL.'includes/admin/pages/'.$admin->page_info['id'].'.php');
include(INCLUDE_URL);
?>